package com.example.service.impl;

import com.example.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

public class MessageActiveqmServiceImpl implements MessageService {

//    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Override
    public void sendMessage(String id) {
        System.out.println("avtiveMQ");
        System.out.println("加入消息队列中进行等待id:"+id);
        jmsMessagingTemplate.convertAndSend("test",id);
    }

    @Override
    public String doMessage() {
        System.out.println("avtiveMQ");
        String id = jmsMessagingTemplate.receiveAndConvert("test", String.class);
        System.out.println("完成该消息处理id:"+id);
        return id;
    }
}
